<%@ taglib prefix='c' uri='http://java.sun.com/jsp/jstl/core'%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%>
<%@taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<link href="<c:url value="/resources/homepage.css" />" rel="stylesheet">

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Story Details</title>
</head>
<body>
	<div id="wrapper">
		<!-- ============ HEADER SECTION ============== -->
		<div id="header">
			<div id="headerlogo"></div>
		</div>
		<!-- ============ NAVIGATION SECTION ============== -->
		<div id="menubar">

			<ul>
			<li><a href="Project">Projects</a></li>
					<li><a href="Backlog">Backlog</a></li>
					<li><a href="SprintPlanning">Sprint Planning</a></li>
					<li><a href="Storyboard1">Sprint Tracking</a></li>
					<li><a href="logout">Logout</a></li>
                    <li><a href="#">${username}</a></li>	
	</ul>
		</div>

		<!-- ============ MIDDLE SECTION ============== -->
		<div id="m1">
			<fieldset>
				<legend>
					<h3>Story Details</h3>
				</legend>
				<form:form action="/saveStory" method="get" modelAttribute="story">
					<table>
						<tr>
							<td>Story Title</td>
							<td><form:input path="story_title" /></td>
							<td></td>
							<td>Actual End Date</td>
							<td><form:input path="actual_end_date" /></td>
						</tr>
						<tr>
							<td>Description</td>
							<td><form:input path="story_description" /></td>
							<td></td>
							<td>Planned Effort</td>
							<%-- 						<td><form:input path="story_point_id"/> --%>
							<td><form:select path="story_point_id">
									<option value=<c:out value="${story_point_id.story_point_id}"/>>${story_point_id.story_point}</option>
									<c:forEach var="storypoints" items="${liststorypoint}">
										<option value=<c:out value="${storypoints.story_point_id}"/>>
											<c:out value="${storypoints.story_point}" />
										</option>
									</c:forEach>
								</form:select></td>
						</tr>
						<tr>
							<td>Owner</td>
							<td><form:input path="story_owner" /></td>
							<td></td>
							<td>Actual Effort</td>
							<td><form:input path="actual_effort" /> <font color="red">hrs</font>
							</td>
						</tr>
						<tr>
							<td>Priority</td>
							<%-- 						<td><form:input path="priority_id" value='${priority_id }'/> --%>
							<!-- 						</td> -->
							<td><form:select path="priority_id">
									<option value=<c:out value="${priority_name.priority_id}"/>>${priority_name.priority_name}</option>
									<c:forEach var="priority" items="${listpriority}">
										<option value=<c:out value="${priority.priority_id}"/>>
											<c:out value="${priority.priority_name}" />
										</option>
									</c:forEach>
								</form:select></td>
							<td></td>
							<td>Remaining Effort</td>
							<td><form:input path="remaining_effort" /> <font color="red">hrs</font>
							</td>
						</tr>
						<tr>
							<td>Planned Start Date</td>
							<td><form:input path="planned_start_date" /></td>
							<td></td>
							<td>Status</td>
							<%-- 						<td><form:input path="status_id" value='${status_id }'/> --%>
							<!-- 						</td> -->
							<td><form:select path="status_id">
									<option value=<c:out value="${status_id.status_id}"/>>${status_id.status_name}</option>
									<c:forEach var="status" items="${liststatus}">
										<option value=<c:out value="${status.status_id}"/>>
											<c:out value="${status.status_name}" />
										</option>
									</c:forEach>
								</form:select></td>
						</tr>
						<tr>
							<td>Planned End Date</td>
							<td><form:input path="planned_end_date" /></td>
							<td></td>
							<td>Complexity</td>
							<%-- 						<td><form:input path="complexity_id" value='${complexity_id}'/> --%>
							<!-- 						</td> -->
							<td><form:select path="complexity_id">
									<option value=<c:out value="${complexity_id.complexity_id}"/>>${complexity_id.complexity_name}</option>
									<c:forEach var="complexity" items="${listcomplexity}">
										<option value=<c:out value="${complexity.complexity_id}"/>>
											<c:out value="${complexity.complexity_name}" />
										</option>
									</c:forEach>
								</form:select></td>
						</tr>
						<tr>
							<td>Actual Start Date</td>
							<td><form:input path="actual_start_date" /></td>
							<td></td>
							<td>Acceptance Criteria</td>
							<td><form:input path="acceptance_criteria" /></td>
						</tr>
					</table>
				</form:form>
			</fieldset>
		</div>

		<div id="main">
			<div align="right">
				<a href="Addtask?project_id=<%=request.getParameter("project_id")%>&sid=<%=request.getParameter("sid")%>"><input type="button" value="Add Task"></a>
			</div>
            <c:choose>
        <c:when test="${not empty listProject}">
			<center>
				<table>
					<tr>
						<th>TASK_ID</th>
						<th>TITLE</th>
						<th>OWNER</th>
						<th>DESCRIPTION</th>
						<th>STATUS</th>
						<th>EDIT</th>
					</tr>

					<%-- 						<c:forEach items="${status}" var="status"> --%>
					<c:forEach var="task" items="${listTask}" varStatus="count">
						<tr>
							<td>${task.task_id }</td>
							<td><a href="EditTask?project_id=<%=request.getParameter("project_id")%>&tid=${task.task_id}">${task.task_title}</a></td>
							<td>${task.task_owner}</td>
							<td>${task.task_description }
							<td>${taskstatus[count.index]}</td>
							<%-- task_story_point is the extracted story point --%>

							<td><table>
									<tr>
										<td><a href="EditTask?tid=${task.task_id}">Edit</a></td>
										<td><a href=#>Close</a></td>
										<td><a href="deleteTask?tid=${task.task_id}">Delete</a></td>
									</tr>
								</table></td>
						</tr>
					</c:forEach>


				</table>
			</center>
            </c:when>
 <c:otherwise>
<b>There are No Projects available!</b>
</c:otherwise>
    </c:choose>

		</div>
		<div id="footer">
			<p>Copyright &copy; 2014 - All Rights Reserved - Spring Computing
				Pvt. Ltd.</p>
		</div>
	</div>


</body>
</html>